/*     */ package com.wgcloud.filter;
/*     */ 
/*     */ import com.wgcloud.config.CommonConfig;
/*     */ import com.wgcloud.entity.AccountInfo;
/*     */ import java.io.IOException;
/*     */ import javax.servlet.Filter;
/*     */ import javax.servlet.FilterChain;
/*     */ import javax.servlet.ServletException;
/*     */ import javax.servlet.ServletRequest;
/*     */ import javax.servlet.ServletResponse;
/*     */ import javax.servlet.annotation.WebFilter;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import javax.servlet.http.HttpSession;
/*     */ import org.slf4j.Logger;
/*     */ import org.slf4j.LoggerFactory;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ @WebFilter(filterName = "authRestFilter", urlPatterns = {"/*"})
/*     */ public class AuthRestFilter
/*     */   implements Filter
/*     */ {
/*  26 */   static Logger log = LoggerFactory.getLogger(com.wgcloud.filter.AuthRestFilter.class);
/*     */   
/*     */   @Autowired
/*     */   CommonConfig commonConfig;
/*     */   
/*  31 */   String[] static_resource = new String[] { "fileSafe/agentList", "shellInfo/agentList", "shellInfo/shellCallback", "fileWarnInfo/agentStateListList", "fileWarnInfo/agentList", "heathMonitor/agentList", "dbTable/agentList", "/systemInfoOpen/", "systemInfo/agentList", "/agentLogGo/minTask", "/agentGo/minTask", "/agentDiskGo/minTask", "login/toLogin", "login/login", "appInfo/agentList", "dockerInfo/agentList", "portInfo/agentList", "license/get", "license/getDaemon", ".css", ".js", ".jpg", ".png", ".ico", ".gif", "font", ".eot", ".woff", ".svg", ".ttf", ".woff2", ".scss", "daping/js/index.html" };
/*     */ 
/*     */   
/*  34 */   String[] dash_views = new String[] { "/dash/main", "/systemInfo/systemInfoList", "/systemInfo/detail", "/systemInfo/chart" };
/*     */   
/*  36 */   String[] daping_views = new String[] { "/daping/index" };
/*     */ 
/*     */   
/*     */   public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
/*  40 */     HttpServletResponse response = (HttpServletResponse)servletResponse;
/*  41 */     HttpServletRequest request = (HttpServletRequest)servletRequest;
/*  42 */     HttpSession session = request.getSession();
/*  43 */     AccountInfo accountInfo = (AccountInfo)session.getAttribute("LOGIN_KEY");
/*  44 */     String uri = request.getRequestURL().toString();
/*  45 */     log.debug("uri----" + request.getRequestURL());
/*  46 */     menuActive(session, uri);
/*     */ 
/*     */     
/*  49 */     if (accountInfo != null && (uri.endsWith("/login/toLogin") || uri.endsWith("wgcloud/") || uri.endsWith("wgcloud"))) {
/*  50 */       response.sendRedirect("/wgcloud/dash/main");
/*     */ 
/*     */       
/*     */       return;
/*     */     } 
/*     */     
/*  56 */     for (String ss : this.static_resource) {
/*  57 */       if (uri.indexOf(ss) != -1) {
/*  58 */         filterChain.doFilter(servletRequest, servletResponse);
/*     */ 
/*     */         
/*     */         return;
/*     */       } 
/*     */     } 
/*     */     
/*  65 */     if (accountInfo == null) {
/*  66 */       for (String ss : this.dash_views) {
/*  67 */         if (uri.indexOf(ss) != -1 && "true".equals(this.commonConfig.getDashView()) && request.getParameter("dashView") != null) {
/*  68 */           filterChain.doFilter(servletRequest, servletResponse);
/*     */ 
/*     */           
/*     */           return;
/*     */         } 
/*     */       } 
/*     */     }
/*     */ 
/*     */     
/*  77 */     if (accountInfo == null) {
/*  78 */       response.sendRedirect("/wgcloud/login/toLogin");
/*     */       
/*     */       return;
/*     */     } 
/*     */     
/*  83 */     filterChain.doFilter(servletRequest, servletResponse);
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public void menuActive(HttpSession session, String uri) {
/*  94 */     if (uri.indexOf("/log/") > -1) {
/*  95 */       session.setAttribute("menuActive", "21");
/*     */       return;
/*     */     } 
/*  98 */     if (uri.indexOf("/dash/main") > -1) {
/*  99 */       session.setAttribute("menuActive", "01");
/*     */       return;
/*     */     } 
/* 102 */     if (uri.indexOf("/systemInfo/systemInfoList") > -1 || uri.indexOf("/systemInfo/detail") > -1 || uri.indexOf("/systemInfo/chart") > -1 || uri.indexOf("/dash/hostDraw") > -1) {
/* 103 */       session.setAttribute("menuActive", "12");
/*     */       return;
/*     */     } 
/* 106 */     if (uri.indexOf("/appInfo") > -1) {
/* 107 */       session.setAttribute("menuActive", "13");
/*     */       return;
/*     */     } 
/* 110 */     if (uri.indexOf("/dockerInfo") > -1) {
/* 111 */       session.setAttribute("menuActive", "14");
/*     */       return;
/*     */     } 
/* 114 */     if (uri.indexOf("/portInfo") > -1) {
/* 115 */       session.setAttribute("menuActive", "15");
/*     */       return;
/*     */     } 
/* 118 */     if (uri.indexOf("/fileWarnInfo") > -1) {
/* 119 */       session.setAttribute("menuActive", "16");
/*     */       return;
/*     */     } 
/* 122 */     if (uri.indexOf("/fileSafe") > -1) {
/* 123 */       session.setAttribute("menuActive", "17");
/*     */       return;
/*     */     } 
/* 126 */     if (uri.indexOf("/mailset") > -1) {
/* 127 */       session.setAttribute("menuActive", "22");
/*     */       return;
/*     */     } 
/* 130 */     if (uri.indexOf("/shellInfo") > -1) {
/* 131 */       session.setAttribute("menuActive", "23");
/*     */       return;
/*     */     } 
/* 134 */     if (uri.indexOf("/dbInfo") > -1) {
/* 135 */       session.setAttribute("menuActive", "41");
/*     */       return;
/*     */     } 
/* 138 */     if (uri.indexOf("/dbTable") > -1) {
/* 139 */       session.setAttribute("menuActive", "42");
/*     */       return;
/*     */     } 
/* 142 */     if (uri.indexOf("/heathMonitor") > -1) {
/* 143 */       session.setAttribute("menuActive", "51");
/*     */       return;
/*     */     } 
/* 146 */     if (uri.indexOf("/dceInfo") > -1) {
/* 147 */       session.setAttribute("menuActive", "61");
/*     */       return;
/*     */     } 
/* 150 */     if (uri.indexOf("/tuopu/tuopuList") > -1) {
/* 151 */       session.setAttribute("menuActive", "71");
/*     */       return;
/*     */     } 
/* 154 */     if (uri.indexOf("/equipment") > -1) {
/* 155 */       session.setAttribute("menuActive", "81");
/*     */       return;
/*     */     } 
/* 158 */     if (uri.indexOf("/report") > -1) {
/* 159 */       session.setAttribute("menuActive", "91");
/*     */       return;
/*     */     } 
/* 162 */     session.setAttribute("menuActive", "11");
/*     */   }
/*     */ }


/* Location:              /Users/zhangyongxin/soft-install/wgcloud/wgcloud-v3.3.5/server/bank/wgcloud-server-release.jar!/BOOT-INF/classes/com/wgcloud/filter/AuthRestFilter.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */